package com.itheima.d3_arraylist;

import java.util.ArrayList;

public class ArrayDemo1 {
    public static void main(String[] args) {
        ArrayList <String> list = new ArrayList<>();
        //添加数据
        list.add("路明非");
        list.add("路鸣泽");
        list.add("绘梨衣");
        list.add("陈墨瞳");
        list.add("楚子航");
        //查看数据
        System.out.println(list);
        list.remove(0);
        //删除后的数据
        System.out.println( list);
        //获取数据
        System.out.println(list.get(0));
        System.out.println(list.get(1));
        System.out.println(list.get(2));
        System.out.println(list.get(3));
        System.out.println("==============================");
        //遍历集合
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        //删除数据
        System.out.println(list.remove("路明非"));//根据元素删除
        System.out.println(list.remove(3));//根据索引删除

        System.out.println( list);
        //修改数据
        System.out.println("=======================");
        list.set(0,"刘亦菲");
        System.out.println(list);

    }
}
